package com.hongxun.budget.utils;

import android.content.Context;
import android.widget.Toast;

/**
 * Toast统一管理类
 */
public class T {

    private T() {
        /* cannot be instantiated */
        throw new UnsupportedOperationException("cannot be instantiated");
    }

    private static Toast toast;

    /**
     * 短时间显示Toast
     * @param context
     * @param message
     */
    public static void showShort(Context context,
                                 String message) {
        if (toast == null) {
            toast = Toast.makeText(context,
                    message,
                    Toast.LENGTH_SHORT);
        } else {
            toast.setText(message);
        }
        toast.show();
    }
    /**
     * 短时间显示Toast
     * @param context
     * @param message
     */
    public static void showShort(Context context,
                                 int message) {
        if (toast == null) {
            toast = Toast.makeText(context,
                    message,
                    Toast.LENGTH_SHORT);
        } else {
            toast.setText(message);
        }
        toast.show();
    }
    /**
     * 长时间显示Toast
     * @param context
     * @param message
     */
    public static void showLong(Context context,
                                 String message) {
        if (toast == null) {
            toast = Toast.makeText(context,
                    message,
                    Toast.LENGTH_LONG);
        } else {
            toast.setText(message);
        }
        toast.show();
    }
    /**
     * 长时间显示Toast
     * @param context
     * @param message
     */
    public static void showLong(Context context,
                                 int message) {
        if (toast == null) {
            toast = Toast.makeText(context,
                    message,
                    Toast.LENGTH_LONG);
        } else {
            toast.setText(message);
        }
        toast.show();
    }

}